package com.richapp.launcher.ui.fragments.child.curtains;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ListView;

import com.richapp.launcher.R;
import com.richapp.launcher.ui.adapter.ChildRoomCurtainsGridAdapter;
import com.richapp.launcher.ui.adapter.ChildRoomCurtainsListAdapter;

public class CurtainsControlFragment extends Fragment {
	private ListView roomCurtainsList = null;
	private GridView roomCurtainsGrid = null;
	private FrameLayout curtains_child_arrow_up = null;
	private ChildRoomCurtainsListAdapter childRoomCurtainsListAdapter = null;
	private ChildRoomCurtainsGridAdapter chiRoomCurtainsGridAdapter = null;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.curtains_control, container,
				false);
		init(view);
		return view;
	}

	private void init(View view) {
		curtains_child_arrow_up = (FrameLayout) view
				.findViewById(R.id.curtains_child_arrow_up);
		curtains_child_arrow_up.setNextFocusDownId(R.id.child_roomcurtains_list);
		roomCurtainsList = (ListView) view
				.findViewById(R.id.child_roomcurtains_list);
		childRoomCurtainsListAdapter = new ChildRoomCurtainsListAdapter(
				getActivity());
		roomCurtainsList.setAdapter(childRoomCurtainsListAdapter);

		// 灯光控制的GridView
		roomCurtainsGrid = (GridView) view
				.findViewById(R.id.child_roomcurtains_gridview);
		chiRoomCurtainsGridAdapter = new ChildRoomCurtainsGridAdapter(getActivity());
		roomCurtainsGrid.setAdapter(chiRoomCurtainsGridAdapter);
		roomCurtainsGrid.setOnItemClickListener(gridItemClick);
	}

	OnItemClickListener gridItemClick = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
               			
		}
	};
	
	@Override
	public void setUserVisibleHint(boolean isVisibleToUser) {
		super.setUserVisibleHint(isVisibleToUser);
		if (isVisibleToUser) {
			Log.v("rq", "isVisibleToUser " + isVisibleToUser);
		} else {
			Log.v("rq", "isVisibleToUser " + isVisibleToUser);
		}
	}

	@Override
	public void setMenuVisibility(boolean menuVisible) {
		// TODO Auto-generated method stub
		super.setMenuVisibility(menuVisible);
	}

	public static CurtainsControlFragment getInstance() {
		return new CurtainsControlFragment();
	}
}
